<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #container{
            width: 500px;
            height: 450px;
            margin: 0 auto;
            margin-top: 2em;
            border: 1px solid rebeccapurple;
            text-align: center;
        }
        #prize{
            width: 100%;
            height: 100px;
            line-height: 100px;
            background-color: #f0f0f0;
            font-size: 30px;
        }
        #result{
            width: 100%;
            height: 300px;
            line-height: 300px;
            background-color: #fff;
            font-size: 30px;
        }
        .item{
            display: none;
        }
        button{
            width: 100%;
            height: 50px;
            background-color: aqua;
            color: #fff;
            border: none;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="container">
        <div id="prize">
            抽奖
        </div>
        <div id="result">
            <div class="item">获得11</div>
            <div class="item">获得22</div>
            <div class="item">获得33</div>
            <div class="item">获得44</div>
            <div class="item">获得55</div>
            <div class="item">获得66</div>
        </div>
        <button id="toggleButton">开始抽奖</button>
    </div>
</body>
</html>

<script>
    var result = document.getElementById('result');
    var items = result.getElementsByClassName('item');
    var btn = document.getElementById('toggleButton');
    var timer = null;
    var index = 0;
    var isRunning = false;

    btn.onclick = function(){
        if (isRunning) {
            clearInterval(timer);
            btn.textContent = '开始抽奖';
        } else {
            timer = setInterval(function(){
                for(var i=0;i<items.length;i++){
                    items[i].style.display = 'none';
                }
                items[index].style.display = 'block';
                index++;
                if(index == items.length){
                    index = 0;
                }
            }, 100);
            btn.textContent = '停止抽奖';
        }
        isRunning = !isRunning;
    }
</script>
